package com.jic.page;

import com.jic.tuple.Tuple;

import java.io.Serializable;
import java.util.List;

/**
 * description: Page
 * date: 2020-01-10 11:58
 * author: wangys
 * version: 1.0
 */
public class Page<T> implements Serializable {
    private static final long serialVersionUID = 3109559160387277161L;
    private int pageNo = 1;
    private int pageSize = 10;
    private List<Tuple<String, String>> orderBys;
    private T lastId;

    public Page(int pageNo, int pageSize) {
        this.pageNo = pageNo;
        this.pageSize = pageSize;
    }

    public int getPageNo() {
        return this.pageNo;
    }

    public int getPageSize() {
        return this.pageSize;
    }

    public List<Tuple<String, String>> getOrderBys() {
        return this.orderBys;
    }

    public T getLastId() {
        return this.lastId;
    }

    public Page<T> setPageNo(int pageNo) {
        this.pageNo = pageNo;
        return this;
    }

    public Page<T> setPageSize(int pageSize) {
        this.pageSize = pageSize;
        return this;
    }

    public Page<T> setOrderBys(List<Tuple<String, String>> orderBys) {
        this.orderBys = orderBys;
        return this;
    }

    public Page<T> setLastId(T lastId) {
        this.lastId = lastId;
        return this;
    }

    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof Page)) {
            return false;
        } else {
            Page<?> other = (Page)o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getPageNo() != other.getPageNo()) {
                return false;
            } else if (this.getPageSize() != other.getPageSize()) {
                return false;
            } else {
                label40: {
                    Object this$orderBys = this.getOrderBys();
                    Object other$orderBys = other.getOrderBys();
                    if (this$orderBys == null) {
                        if (other$orderBys == null) {
                            break label40;
                        }
                    } else if (this$orderBys.equals(other$orderBys)) {
                        break label40;
                    }

                    return false;
                }

                Object this$lastId = this.getLastId();
                Object other$lastId = other.getLastId();
                if (this$lastId == null) {
                    if (other$lastId != null) {
                        return false;
                    }
                } else if (!this$lastId.equals(other$lastId)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof Page;
    }

    public int hashCode() {
        int PRIME = 1;
        int result = 1;
        result = result * 59 + this.getPageNo();
        result = result * 59 + this.getPageSize();
        Object $orderBys = this.getOrderBys();
        result = result * 59 + ($orderBys == null ? 43 : $orderBys.hashCode());
        Object $lastId = this.getLastId();
        result = result * 59 + ($lastId == null ? 43 : $lastId.hashCode());
        return result;
    }

    public String toString() {
        return "Page(pageNo=" + this.getPageNo() + ", pageSize=" + this.getPageSize() + ", orderBys=" + this.getOrderBys() + ", lastId=" + this.getLastId() + ")";
    }

    public Page() {
    }
}
